package com.banciyuan.bcywebview.biz.circles.smooth.viewholder;

import android.content.Context;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.biz.groupdetail.NewTeamDetailActivity;
import com.banciyuan.bcywebview.utils.intent.gotoUtil;

import de.greenrobot.daoexample.model.Timeline;

/**
 * Created by squall on 2017/4/17.
 */

public class SmallGroupHolder extends ViewBaseItem {

    private TextView name;
    private TextView count;

    public SmallGroupHolder(View itemView) {
        super(itemView);
        name = (TextView) itemView.findViewById(R.id.group_name);
        count = (TextView) itemView.findViewById(R.id.join_num);
    }

    public void renderGroup(final Context mContext, final Timeline mTimeline) {
        if (!TextUtils.isEmpty(mTimeline.getName())) {
            name.setText(Html.fromHtml(mTimeline.getName()));
        }
        if (!TextUtils.isEmpty(mTimeline.getPost_num())) {
            count.setText(String.format(mContext.getString(R.string.join_talk), mTimeline.getPost_num()));
        }
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gotoUtil.gotoAct(mContext, NewTeamDetailActivity.class, mTimeline.getGid());
            }
        });
    }
}
